1. Field of the Invention
The present invention relates to an image processing apparatus that extracts an edge feature from an image and a control method thereof.
2. Description of the Related Art
Heretofore, various image retrieval methods and recognition methods using edge features have been proposed. A typical edge extraction method involves performing a calculation per pixel using differential filters on a range that includes neighboring pixels. Filters used include a Prewitt filter, Sobel filter, Robison filter, and Kirsch filter. In the case where edge features are used in image retrieval or the like, the edge distribution in a partial area of the image is used as a feature amount in many cases.
The edge histogram disclosed in “Efficient Use of MPEG-7 Edge Histogram Descriptor” (Chee Sun Won et al., ETRI Journal, Vol. 24, No. 1, February 2002; hereinafter, document 1) uses an edge extraction method required to obtain edge distributions at a lower calculation cost compared to a method using the Sobel filter or the like. The edge extraction method disclosed in document 1 will now be described.
Firstly, an input image 10 is divided into 4×4 sub-images 11, such as shown in FIG. 12. The respective sub-images are further divided into square image blocks 12 so as to approximate a prescribed number. Next, the image blocks are further divided into four (2×2) compartments 13, and average luminances a(0) to a(3) are determined for the respective compartments. Next, the respective edge strengths m_v, m_h, m_d45, m_d135 and m_nd are calculated, using filters corresponding to the four directions shown in FIGS. 13A to 13D, that is, (a) vertical, (b) horizontal, (c) 45 degree and (d) 135 degree, and the non-direction shown in FIG. 13E. For example, m_v will be represented by the following expression when a(n) expresses the average luminance of each of the four compartments into which the image blocks 12 are divided (note that n=0 to 3, and shows the number attached to each of the four compartments).m—v=|1×a(0)+(−1)×a(1)+1×a(2)+(−1)×a(3)|  (1)
When the maximum value among the edge strengths m_v, m_h, m_d45, m_d135 and m_nd is greater than or equal to a prescribed threshold A, the direction of the maximum value is determined to be the direction of the edge of the target image block. The threshold A is the minimum strength value at which an edge is considered to exist. An edge histogram Eij is calculated by counting the directions of each image block 12 included in a sub-image 11. Note that i=0 to 4 corresponds to the filters shown in FIGS. 13A to 13E, and j=0 to 15 corresponds to the sub-images 11. The edge histogram Eij thus obtained is used as the feature amount.
However, the edge extraction method shown in document 1 is not always able to satisfactorily obtain edge features despite the advantage of having a small calculation cost compared to edge extraction methods that use the Sobel filter or the like. The case in which this edge extraction method is applied to image retrieval that targets the lines of a binary image will be described as an example in which this problem is markedly evident.
In FIG. 14A, four equidistant lines 21 overlap a total of 16 areas respectively obtained by dividing four image blocks of width 2d in four. With the lines of binary images, hatching composed on equidistantly spaced straight lines is often used in order to represent areas of particular density, such as with the areas corresponding to the lines 21. It is not always possible to extract hatching, depending on the relation between the size of the image blocks 12 and the spacing of the lines 21, with respect to such hatched areas. For example, consider the case where the size of the image blocks 12 and the spacing of the lines 21 are synchronized, as shown in FIG. 14A. Assume that the size (width and height) of the image blocks 12 is 2d, the thickness (width) of the lines 21 is b, and the spacing between the lines 21 is g. When these values are in the relation shown in the following equation (2), for example, the a(n) values in equation (1) will all be the same. Thus, the m_v value will be 0, making it impossible to detect the vertical lines, despite the vertical lines clearly existing.d=b+g  (2)
In the case where image retrieval using edge histograms is performed, an image can be retrieved if the edge histogram of an image provided by a query is similar to the edge histogram of an image stored in a database. Consequently, the feature amounts of the edge histograms in the database and the query will be similar if it is always impossible to detect an edge even when the lines 21 exists such as in FIG. 14A. However, in the case where the size of the image blocks 12 and the spacing of the lines 21 are slightly out of sync, as in FIG. 14B, it may or may not be possible to detect an edge, depending on the extent of the deviation. For example, consider the case where the image blocks 12 and the hatched lines 21 are disposed in a relation such as FIG. 14B. The values in equation (1) will be as follows when the size (width and height) of the image blocks 12 is 2d, the deviation of the left edge of the line 21 from the left edge of the image block 12 is a, the thickness of the lines 21 is b, the spacing between the lines 21 is g, the luminance of the lines 21 is 0, and the luminance of the white background is 255.a(0)=a(2)=(d−(b−a)×255)/d a(1)=a(3)=((d−b)×255)/d m—v=(a×255)/d  (3)
Consequently, assuming the size of the image blocks is the same for the image in the query and the image in the database, the value of m_v will be larger or smaller than the threshold A depending on the value of a, either enabling or preventing an edge from being detected.
This state expands in the direction of the hatched lines 21 as the lines 21 increase in length, and also expands perpendicular to the lines 21 depending on conditions such as the thickness and spacing of the lines 21. Hatching is also sometimes applied to wide areas, which leads to the feature amounts of the edge histograms differing greatly even with images that look extremely similar, and results in not being able to retrieve similar images.